const express = require('express')
const app = express()
const http = require('http')
const server = http.createServer(app)
const socket = require('socket.io')

server.listen(8080, () => {
  console.log('8000端口服务已经打开')
})

socket.listen(server).on('connection', function(client) {
  client.on('message', function(msg) {
    client.send('webSocket发来贺电')
  })

  client.on('disconnect', function() {
    console.log('客户端已经关闭')
  })
})